
<?php
	require_once 'Connect.class.php';
	require_once 'DanhMuc.class.php';
	/**
	* 
	*/
	/**
	* 
	*/
	class GioiTinh extends DanhMuc{
		
		public function __construct(){
			# code...
		}
		public function getInfo($maGT){

			$conn= new Connect();

			$conn->Query("SELECT * FROM tbl_gioi_tinh WHERE maGT='".$maGT."'; ");	

			while ($row=$conn->Fetch()) {	

				$this->ma=$row['maGT'];
				
				$this->ten=$row['tenGT'];
			}
			// dong ket noi
			$conn->close();
		}
		public function capnhat(){
			$sql="UPDATE tbl_gioi_tinh SET tenGT='".$this->ten."' WHERE maGT='".$this->ma."'";
			$conn=new Connect();
			$conn->Query($sql);
			$conn->close();
		}

		public function them(){

			$sql="INSERT INTO tbl_gioi_tinh(maGT,tenGT) values('".$this->ma."','".$this->ten."')";

			$conn=new Connect();

			$conn->Query($sql);

			$conn->close();
			
		}
		public function checkNo($maGT){

			$rs=false;

			$conn= new Connect();

			$conn->Query("SELECT COUNT(maGT) as dem FROM tbl_gioi_tinh WHERE maGT='".$maGT."'; ");	

			while ($row=$conn->Fetch()) {	
				if ($row['dem']==1){
					$rs=true;
				}
			}
			// dong ket noi
			$conn->close();
			return $rs;
		}
		public function xoa(){
			$sql="DELETE FROM tbl_gioi_tinh WHERE maGT='".$this->ma."'";
			$conn=new Connect();
			$conn->Query($sql);
			$conn->close();

		}

		public function ds(){
			$ds=array();
			$conn= new Connect();
			$conn->Query("SELECT * FROM tbl_gioi_tinh");
			$index=0;
			while ($row=$conn->Fetch()) {
				$gt= new GioiTinh();
				$gt->setMa($row['maGT']);
				$gt->setTen($row['tenGT']);
				$ds[$index]=$gt;
				$index++;
			}
			// dong ket noi
			$conn->close();
			return $ds;
		}
	}

?>